// ----------------------------------
// RSDK Project: Sonic Pocket Reventure
// Script Description: Blueprint Setup Object
// Script Author: Christan Whitehead/Simon Thomley/Tails LP
// ----------------------------------

//-------Aliases-------//
private alias 39 : TYPE_TESTSETUP

// Function declarations
reserve function BlueprintSetup_Function93
reserve function BlueprintSetup_Function94

// Static Values
public value ZoneSetup_value33 = 0;
public value BlueprintSetup_value29 = 0;
public value BlueprintSetup_value30 = 0;
public value BlueprintSetup_value31 = 0;

// Tables

public table BlueprintSetup_table0
	0x500000, 0x3B00000, 0, 11, 8, 91, 56, 1, 40, 7, 8, 87, 56, 1, 40, 8, 8, 47, 56, 1, 40, 7, 8, 204, 56, 1, 40, 7, 8, 32, 56, 1, 40, 9, 8, 43, 56, 1, 40, 28, 8, 61, 56, 1, 40, 24, 8, 30, 56, 1, 40, 44, 8, 22, 56, 1, 40, 21, 8, 42, 56, 1, 40, 107, 8, 255, 8, 33, 0, 203, 4, 44, 0, 12, 4, 11, 0, 23, 8, 20, 0, 15, 4, 4, 0, 19, 8, 16, 56, 1, 40, 10, 8, 39, 56, 1, 40, 8, 8, 42, 56, 1
end table

public table BlueprintSetup_table1
	0x500000, 0x3B40000, 0, 11, 8, 91, 56, 1, 40, 10, 8, 75, 4, 12, 52, 1, 36, 24, 4, 19, 52, 1, 36, 7, 4, 8, 0, 27, 8, 55, 56, 1, 40, 4, 32, 5, 0, 29, 4, 25, 0, 11, 8, 34, 0, 11, 8, 30, 56, 1, 40, 9, 8, 202, 56, 1, 40, 9, 8, 35, 56, 1, 40, 8, 8, 45, 56, 1, 40, 14, 8, 17, 0, 7, 8, 52, 56, 1, 40, 17, 8, 33, 56, 1, 40, 33, 8, 2, 0, 29, 8, 14, 56, 1, 40, 6, 8, 5, 0, 13, 4, 9, 0, 11, 48, 1, 32, 6, 8, 6, 56, 1, 40, 6, 8, 16, 56, 1, 40, 5, 8, 33, 0, 8, 4, 11, 0, 21, 8, 9, 0, 31, 48, 1, 32, 6, 0, 2, 8, 28, 0, 28, 4, 5, 0, 5, 8, 25, 56, 1, 40, 2, 8, 28, 0, 6, 4, 9, 0, 6, 8, 31, 0, 45, 56, 1, 40, 5, 0, 2, 8, 9, 0, 7, 8, 10, 0, 30, 8, 12, 0, 37, 4, 17, 0, 22, 8, 20, 56, 1, 40, 11, 8, 52, 56, 1, 40, 12
end table

public table BlueprintSetup_table2
	0x500000, 0x3B00000, 0, 11, 8, 92, 56, 1, 40, 12, 8, 82, 2, 12, 0, 24, 48, 1, 32, 26, 0, 3, 8, 2, 56, 1, 40, 88, 8, 2, 0, 28, 2, 16, 50, 1, 34, 7, 2, 5, 50, 1, 34, 2, 2, 5, 50, 1, 34, 3, 2, 3, 50, 1, 34, 2, 2, 4, 8, 105, 0, 109, 8, 12, 56, 1, 40, 44, 8, 51, 56, 1, 40, 33, 8, 17, 56, 1, 40, 40, 8, 31, 56, 1, 40, 39, 8, 24, 56, 1, 40, 64, 8, 17, 56, 1, 40, 15, 8, 241, 0, 29, 48, 1, 32, 18, 0, 4, 48, 1, 32, 30, 33, 3, 1, 171, 0, 15, 2, 12, 50, 1, 34, 7, 2, 4, 50, 1, 34, 2, 2, 6, 50, 1, 34, 2, 2, 4, 50, 1, 34, 5, 2, 22, 0, 2, 8, 47, 0, 6
end table

public table BlueprintSetup_table3
	0x500000, 0x3B00000, 8, 91, 56, 1, 40, 9, 8, 83, 56, 1, 40, 5, 8, 52, 56, 1, 40, 8, 8, 160, 0, 8, 8, 26, 56, 1, 40, 3, 32, 2, 0, 6, 4, 5, 0, 13, 8, 44, 56, 1, 40, 5, 8, 17, 0, 16, 8, 13, 8, 5, 8, 42, 0, 52, 8, 30
end table

public table BlueprintSetup_table4
	0x13E80000, 0x2AC0000, 0, 17, 8, 255, 8, 31, 0, 219
end table

public table BlueprintSetup_Deform
	1, 2, 1, 3, 1, 2, 2, 1, 2, 3, 1, 2, 1, 2, 0, 0
	2, 0, 3, 2, 2, 3, 2, 2, 1, 3, 0, 0, 1, 0, 1, 3
	1, 2, 1, 3, 1, 2, 2, 1, 2, 3, 1, 2, 1, 2, 0, 0
	2, 0, 3, 2, 2, 3, 2, 2, 1, 3, 0, 0, 1, 0, 1, 3
end table

function BlueprintSetup_Function93
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility.ogg", 2, 1)
			SwapMusicTrack("SPEEDSHOES.ogg", 0, 0, 1)
			break
		case 2
			SetMusicTrack("SPEEDSHOES.ogg", 0, 1)
			SwapMusicTrack("Invincibility.ogg", 2, 0, 1)
			break
		case 4
		case 6
		case 7
			SetMusicTrack("SPEEDSHOES.ogg", 0, 1)
			SwapMusicTrack("Invincibility.ogg", 2, 0, 1)
			break
		end switch
	else
		stage.musicFlag = 1
	end if
end function


function BlueprintSetup_Function94
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility.ogg", 2, 1)
			SwapMusicTrack("Blueprint.ogg", 0, 0, 1)
			break
		case 2
			SetMusicTrack("Blueprint.ogg", 0, 1)
			SwapMusicTrack("Invincibility.ogg", 2, 0, 1)
			break
		case 4
		case 6
		case 7
			SetMusicTrack("Blueprint.ogg", 0, 1)
			SetMusicTrack("Invincibility.ogg", 2, 1)
			break
		end switch
	else
		stage.musicFlag = 2
	end if
end function


event ObjectMain
	if BlueprintSetup_value30 != 0
		BlueprintSetup_value30 = 0
		object.value4--
		if object.value4 <= 0
			object.value4 = 31
			if object.value5 == 0
				if credits.screen == 0
					PlaySfx(SfxName[Waterfall], 0)
					StopSfx(SfxName[Waterfall Loop])
				end if
				object.value5 = 1
			else
				if credits.screen == 0
					StopSfx(SfxName[Waterfall])
					PlaySfx(SfxName[Waterfall Loop], 0)
				end if
			end if
		end if
		SetSfxAttributes(SfxName[Waterfall], -1, BlueprintSetup_value31)
		SetSfxAttributes(SfxName[Waterfall Loop], -1, BlueprintSetup_value31)
	else
		object.value5 = 0
		object.value4 = 0
	end if
	if object.state < 5
		object.value3++
		if object.value3 == 6
			object.value3 = 0
			RotatePalette(0, 188, 191, 0)
			BlueprintSetup_value29++
			BlueprintSetup_value29 &= 15
		end if
	end if

end event


event ObjectStartup
	arrayPos0 = 0
	while arrayPos0 < 576
		temp0 = arrayPos0
		temp0 &= 63
		GetTableValue(stage[arrayPos0].deformationData2, temp0, BlueprintSetup_Deform)
		arrayPos0++
	loop
	SetMusicTrack("Blueprint.ogg", 0, 1)
	SpeedUpMusic = BlueprintSetup_Function93
	SlowDownMusic = BlueprintSetup_Function94
	animalType1 = TypeName[Pocky]
	animalType2 = TypeName[Flicky]
	object[10].type = TypeName[Blueprint Setup]
	object[10].priority = PRIORITY_ACTIVE
	BlueprintSetup_value29 = 0
end event

event RSDKDraw
	DrawSprite(0)
end event

event RSDKLoad
	LoadSpriteSheet("Global/Display.gif")
	SpriteFrame(-16, -16, 32, 32, 1, 143)
end event
